home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-10-20 | 2.4 KB | 58 lines | [TEXT/GEOL] |
- Item 3175905 19-Oct-89 11:58
-
- From: ROSENSTEIN1 Rosenstein, Larry
-
- To: D4280 IDS, Robert Pappas, AST
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re MPW C++
-
- Bob,
-
- Regarding your questions:
-
- (1) CFront converts the symbols in your program into mangled names that encode
- more type and scoping information. Mangled names always (I think) begin with 2
- underscores and a capital letter. The warning you saw referred to the fact
- that MacApp uses a couple of symbols that also begin this way, so there may be
- a compilation problem.
-
- (2) CFront will give a warning if you declare a parameter that isn't used. You
- can eliminate the warning by eliminating the parameter name. For example: void
- Foo(int parm1, short) could be use if the second parameter is never referenced.
-
- (3) The message about TBirdView::Draw hiding TView::Draw does not refer to
- overridden methods. It may indicate an error in writing the override, however.
-
- In full C++, it is possible to overload a method: you can have multiple
- versions of a routine that take different parameters.
-
- This applies to methods as well. Suppose class TFoo defines a virtual method
- Bar. One version takes a single int, and another takes an int and a short.
- (IE, TFoo::Bar(int) and TFoo::Bar(int, short).) This is perfectly legal in
- C++, and the compiler will call the appropriate method based on the parameters.
-
- One rule in C++ is that if you override one version of a virtual method, you
- must override all versions. If you don't you will get the <X> hides <Y>
- warning.
-
- In the example, if TSubFoo overrides Bar(int) but not Bar(int, short), then you
- will get the warning.
-
- The warning also can indicate that you made a mistake when overriding a method.
- Suppose TSubFoo defines Bar(int) as above and Bar(int, int). The latter method
- is different from the inherited method (TFoo::Bar(int, short)) and is
- considered a new overloaded method. Since you still haven't overridden
- TFoo::Bar(int,short) you will get the message.
-
- You have to be careful with overloading. C++ does not require that you mark a
- method overidden. If you do mis-type the parameter list you will be
- overloading a routine, which is perfectly legal. You won't dicover the mistake
- unless you happen to get a warning, or until you look at what happens at
- runtime.
-
-
- Larry
-
-